//
//  SearchVC.swift
//  simpleStopwatch
//
//  Created by macvivi on 2021/7/12.
//

import UIKit

class SearchVC: UIViewController {
    
    @IBOutlet var tableView: UITableView!
    @IBOutlet var radarBackView: UIView!
    
    lazy var radarView: RadarAnimationView = {
        let radarView:RadarAnimationView = RadarAnimationView(frame: radarBackView.bounds)
        radarView.image = UIImage(named: "searchCenter")
        return radarView
    }()
    
    var isSearch = false {
        willSet{
            if newValue {
                //显示searchView
                radarBackView.addSubview(radarView)
                tableView.isHidden = true
            } else {
               //显示tableView
                radarView.removeFromSuperview()
                tableView.isHidden = false
            }
        }
    }

    @objc func rightBarBtnItemClick(){
        print("刷新")
        isSearch = false
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "搜索"
        
        let item = UIBarButtonItem(image: UIImage(named: "刷新"), style: .plain, target: self, action: #selector(rightBarBtnItemClick))
        navigationItem.rightBarButtonItem = item
        
        tableView.dataSource = self
        tableView.delegate = self

        isSearch = true
        
    }
    

    deinit {
        print("searchVC deinit")
    }
}

extension SearchVC: UITableViewDataSource {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        5
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "searchCell", for: indexPath)
        cell.textLabel?.text = "156"
        return cell
    }
    
    
}

extension SearchVC: UITableViewDelegate {
    
}
